package com.cn.goodsadmin.service;

import com.cn.goodsadmin.common.PageQueryResult;
import com.cn.goodsadmin.dao.DestDTO;
import com.cn.goodsadmin.po.App;
import com.cn.goodsadmin.po.Words;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("WordsService")
public class WordsService extends BaseService{

    public PageQueryResult<DestDTO> findAllWords(int pageindex, int pagesize, int appid)throws Exception{
        App app=appDao.findAppById(appid);
        if(app!=null){
            String wxnumber=app.getcWxnumber();
            PageQueryResult<DestDTO> pageQueryResult= wordsDao.findAllWordsbyAppid(pageindex,pagesize,wxnumber);
            return pageQueryResult;
        }
        return null;
    }

    public PageQueryResult<DestDTO>  filterWordsByOpenid(int pageindex, int pagesize,String openid,int  appid)throws Exception{
        App app=appDao.findAppById(appid);
        if(app!=null){
            String wxnumber=app.getcWxnumber();
            return  wordsDao.findAllWordsbyAppidAndOpenId(pageindex,pagesize,wxnumber,openid);
        }
        return null;
    }

    public List<Words>  findCallBackWords(Words words)throws Exception{
        return wordsDao.findCallBackWords(words);
    }

    public Words  findLastCallBackByOpenid(String openid,String wxnumber)throws Exception{
        return wordsDao.findLastUserCallBack(openid,wxnumber);
    }
}
